CDS_HOME=/benchmark/phoenix/b15/; export CDS_HOME
JAVA_HOME=/usr/java; export JAVA_HOME
PATH=.:${CDS_HOME}/bin:${JAVA_HOME}/bin:${PATH}; export PATH
cd $CDS_HOME/modules/internal/perftest/src/scripts/cdsa_wrapper_scripts/

#deploy manually

ssh -L8081:10.60.11.31:8080 -l root jewel3      # referenced the 192.18.47.156

# checking CDS
ssh -L4080:10.60.11.27:4080 -l root jewel3      # referenced the 192.18.47.156

cdsetup.sh easy_setup                           # Setup cds server.
setup_z.sh

cd ../cdsadmin
rcp jzou* oracle@db2:

export ORACLE_SID=CDSTWO1
export PREFIX=PRFII
export PREFIX=jzou

sqlplus system/oracle

select table_name from tabs;

sqlplus / as sysdba <<EOF
grant connect , resource to ${PREFIX}_ps_owner identified by cdsperf;
grant connect , resource to ${PREFIX}_vs_owner identified by cdsperf;
exit
EOF

sqlplus system/oracle > /tmp/tabs <<EOF
sqlplus ${PREFIX}_vs_owner/cdsperf > /tmp/tabs <<EOF
set head off
select table_name from tabs;
exit
EOF

sqlplus ${PREFIX}_vs_owner/cdsperf <<EOF
select count(*) from RESOURCE_INSTANCE_FIELD;
select count(*) from RESOURCE_CLASS_FIELD;
describe category_item;
exit
EOF

sqlplus ${PREFIX}_vs_owner/cdsperf <<EOF
drop table log_category_item;
drop table log_category_item_map;
drop table log_ven_pricing_model_map;
drop table log_handset_content_map;
drop table log_instance_capability_map;
drop table log_large_capability_map;
drop table log_resource_content_data;
drop table CATEGORY_ITEM_TMP;
EOF



sqlplus ${PREFIX}_vs_owner/cdsperf <<EOF
@${PREFIX}_vs.sql
EOF

sqlplus ${PREFIX}_ps_owner/cdsperf <<EOF
@${PREFIX}_ps.sql
EOF

grep HANDSET /tmp/tabs

sqlplus ${PREFIX}_ps_owner/cdsperf <<EOF
select * from HANDSET_CONTENT_MAP
EOF


dump(){
echo
echo $1
echo
sqlplus ${PREFIX}_vs_owner/cdsperf <<EOF
select * from $1;
EOF
}

for i in `cat /tmp/tabs`
do
dump $i
done

sqlplus ${PREFIX}_vs_owner/cdsperf > /tmp/output <<EOF
@/tmp/SQLCMD$$
EOF

sqlplus ${PREFIX}_vs_owner/cdsperf <<EOF
select 'YESFOUND', HANDSET_ID from HANDSET;
exit
EOF

firefox http://host:port/admin/main/search_update?action=rebuild
firefox http://host:port/vsadmin/main/search_update?action=rebuild
http://host:port/admin/main/search_update?action=delete_all
http://host:port/vsadmin/main/search_update?action=delete_all

# Please reference the CDS_SLAMD_MLK.sh

# performance tuning
# ------------------
#   The CDS server hung at 32 threads on 1 client. After checking the CDS. I there are 21 openend socket
# listening the 4080 which is the CDS listening port.
# Checking $CDS_HOME/cds/conf/DatabasePools
# DatabasePools.properties:service_pool.db.pool.size.max=20
# Conjecture :
#   The  service_pool.db.pool.size.max=20 is the bottle neck of CDS performance.

